package com.syn.config;

import sun.management.snmp.jvmmib.JVM_MANAGEMENT_MIBOidTable;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.List;

public class SynInvocationHandle implements InvocationHandler {
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        System.out.println(method.getName());
        Class<?> returnType = method.getReturnType();
        Type t = method.getAnnotatedReturnType().getType();
      //  String typeName = returnType;
        if (t.getTypeName().equals("void")){
            System.out.println("返回值为 void");
        }
        if(t instanceof List){
            System.out.println("返回为list");
        }
        if (t instanceof Object){
            System.out.println("返回单个对象");
        }

        if (args!=null&& args.length>0){
            List<Object> objects = Arrays.asList(args);
            for (Object object : objects) {
                System.out.println(object);
            }
        }

        //这是需要查询数据库的操作
        return null;
    }
}
